import { defineConfig, loadEnv } from 'vite'
import vue from '@vitejs/plugin-vue'
import path from 'path'
// https://vitejs.dev/config/
export default defineConfig(({ command, mode }) => {
  const env = loadEnv(mode, process.cwd(), '')
  console.log(env)
  return {
    plugins: [vue()],
    resolve: {
      alias: {
        '@': path.resolve(__dirname, './src'),
      },
    },
    server: {
      host: '0.0.0.0',
      proxy: {
        '/api': {
          target: env.VITE_APP_API_BASE_URL,
          changeOrigin: true,
          rewrite: (path) => path.replace(/^\/api/, ''),
        },
        '/vmss': {
          target: 'https://vms.cn-huadong-1.xf-yun.com',
          // target: 'http://172.31.103.99:8888',
          changeOrigin: true,
          secure: false,
          rewrite: (path) => path.replace(/^\/vmss/, ''),
        },
        '/vms3dPrefix': {
          target: 'http://vms.cn-huadong-1.xf-yun.com',
          changeOrigin: true,
          secure: false,
          rewrite: (path) => path.replace(/^\/vms3dPrefix/, ''),
        },
        '/individuation': {
          target: 'https://evo-hu.xf-yun.com',
          changeOrigin: true,
        },
      },
    },
  }
})
